package cn.tedu._05weibo.config;

import cn.tedu._05weibo.interceptors.MyInterCeptor;
import cn.tedu._05weibo.interceptors.UserLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MvcInterCeptor implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截所有
//        registry.addInterceptor(new MyInterCeptor());

        //拦截微博模块的所有请求
//        registry.addInterceptor(new MyInterCeptor()).addPathPatterns("/v1/weibo/**");

        //拦截评论模块除了selectByWeiboId之外的
//        registry.addInterceptor(new MyInterCeptor()).addPathPatterns("v1/comment/**").excludePathPatterns("/v1/comment/selectByWeiboId");

        //校验用户登录状态的拦截器
        registry.addInterceptor(new UserLoginInterceptor()).addPathPatterns("/v1/weibo/insert","/v1/comment/insert");
    }
}